/*
 * @Author: your name
 * @Date: 2022-03-28 13:35:27
 * @LastEditTime: 2022-03-29 11:25:18
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \blog_web\src\store\modules\user.js
 */
// 导入本地存储的函数
import db from '@/util/localstorage'

const state = () => ({
  // 用户的信息
  user: {},
  // 用户的token
  token: ''
})
const getters = {}
const mutations = {
  // 设置user
  setUser(state, user) {
    // 保存到本地存储
    db.save('user', user)
    // 保存到vuex
    state.user = user
  },
  // 设置token
  setToken(state, token) {
    db.save('token', token)
    state.token = token
  }
}
const actions = {}
export default {
  namespaced: true,
  getters,
  state,
  mutations,
  actions
}
